#!/usr/bin/env python

from test0 import *

w = Widget(WidgetInd("window"))
g = Widget(WidgetInd("group"))
b = Widget(WidgetInd("button"))
b1 = Widget(WidgetInd("button"))
b2 = Widget(WidgetInd("button"))
g1 = Widget(WidgetInd("group"))
b3 = Widget(WidgetInd("button"))
t = Widget(WidgetInd("field"))

def simple_callback(sender):
  f = WidgetResource()

  print "Trying to get args"

  t.get_arg (WidgetArg(
    "get",
    [
    ("text", f),
    ]))

  print f.get()

  b3.set_arg (WidgetArg(
    "set",
    [
    ("text", f.get()),
    ]))


if __name__ == "__main__":
  init()

  w.create()

  g.set_default_parent()
  g.create()

  b.set_default_parent()
  b.create()
  b.set_arg (WidgetArg(
    "set",
    [
    ("text", "hello")
    ]))
  b.set_callback("sender", simple_callback)

  b1.set_default_parent()
  b1.create()
  b1.set_arg (WidgetArg(
    "set",
    [
    ("text", "hello1"),
    ("color", "blue"),
    ]))
  b1.set_callback("sender", simple_callback)

  b2.set_default_parent()
  b2.create()
  b2.set_arg (WidgetArg(
    "set",
    [
    ("text", "hello2"),
    ("color", "blue"),
    ]))
  b2.set_callback("sender", simple_callback)

  g1.set_default_parent()
  g1.create()

  b3.set_default_parent()
  b3.create()
  b3.set_arg (WidgetArg(
    "set",
    [
    ("text", "hello3"),
    ("color", "blue")
    ]))

  t.set_default_parent()
  t.create()
  t.set_arg (WidgetArg(
    "set",
    [
    ("text", "hello3"),
    ]))

  w.realize()

  main_loop()

